package nc.impl.am.leasehold;

import nc.bs.am.datasource.BillPrintDataSource;
import nc.bs.pub.pf.IPrintDataGetter;
import nc.bs.pub.pf.IQueryVoData;
import nc.bs.pub.pf.QueryVoContext;
import nc.impl.am.common.AppendDataManager;
import nc.impl.am.common.DataBaseDataInfo;
import nc.impl.am.common.ExtendedBaseDAO;
import nc.impl.am.common.VoDataInfo;
import nc.ui.pub.print.IDataSource;
import nc.vo.am.leasehold.VerifyHeadVO;
import nc.vo.am.leasehold.VerifyVO;
import nc.vo.pub.BusinessException;
import nc.vo.pub.SuperVO;

public class QueryVerifyData extends ExtendedBaseDAO implements IQueryVoData, IPrintDataGetter {

	public Object queryBodyVO(QueryVoContext qvc) throws BusinessException {
		VerifyHeadVO headVO = (VerifyHeadVO) queryHeadVO(qvc);
		VerifyVO billVO = new VerifyVO();
		billVO.setHeadVO(headVO);
		return new VerifyBO().retrieveVerifyBodyVOs(billVO);
	}

	public Object queryHeadVO(QueryVoContext qvc) throws BusinessException {
		SuperVO headVO = queryHeadVO(VerifyHeadVO.class, "pk_paid_receive", qvc);
		if (headVO != null) {
			new ReCalculateImpl().setPk_cubasdoc(this, headVO);
		}
		DataBaseDataInfo[] dataBaseDataInfos = new DataBaseDataInfo[] {
				new DataBaseDataInfo("sm_user", "cuserid", new String[] { "user_name" }),
				new DataBaseDataInfo("sm_user", "cuserid", new String[] { "user_name" }),
				new DataBaseDataInfo("sm_user", "cuserid", new String[] { "user_name" }),
				new DataBaseDataInfo("bd_corp", "pk_corp", new String[] { "unitname" }),
				new DataBaseDataInfo("bd_corp", "pk_corp", new String[] { "unitname" }),
				new DataBaseDataInfo("bd_deptdoc", "pk_deptdoc", new String[] { "deptname" }),
				new DataBaseDataInfo("bd_deptdoc", "pk_deptdoc", new String[] { "deptname" }),
				new DataBaseDataInfo("bd_cubasdoc", "pk_cubasdoc", new String[] { "custname" }),
				new DataBaseDataInfo("bd_cubasdoc", "pk_cubasdoc", new String[] { "custname" }),
				new DataBaseDataInfo("bd_bankaccbas", "pk_bankaccbas", new String[]{"accountcode","accountname"}),
				new DataBaseDataInfo("bd_bankaccbas", "pk_bankaccbas", new String[]{"accountcode","accountname"}),
				new DataBaseDataInfo("bd_balatype", "pk_balatype", new String[]{"balanname"}),
				new DataBaseDataInfo("bd_accsubj", "pk_accsubj", new String[]{"subjname"}),
				new DataBaseDataInfo("bd_currtype", "pk_currtype", new String[]{"currtypename"}),
				new DataBaseDataInfo("bd_accsubj", "pk_accsubj", new String[]{"subjname"})
		};
		VoDataInfo[] voDataInfos = new VoDataInfo[] { 
				new VoDataInfo("pk_maker", new String[] { "maker_name" }),
				new VoDataInfo("pk_updater", new String[] { "updater_name" }),
				new VoDataInfo("pk_checker", new String[] { "checker_name" }),
				new VoDataInfo("pk_corp_in", new String[] { "corp_in_name" }),
				new VoDataInfo("pk_corp_out", new String[] { "corp_out_name" }),
				new VoDataInfo("pk_usedept_out", new String[] { "usedept_out_name" }),
				new VoDataInfo("pk_usedept_in", new String[] { "usedept_in_name" }),
				new VoDataInfo("pk_cubasdoc_in", new String[] { "cumandoc_in_name" }),
				new VoDataInfo("pk_cubasdoc_out", new String[] { "cumandoc_out_name" }),
				new VoDataInfo("pk_accbank_out", new String[]{"accbank_out_code","accbank_out_name"}),
				new VoDataInfo("pk_accbank_in", new String[]{"accbank_in_code","accbank_in_name"}),
				new VoDataInfo("pk_balatype", new String[]{"balatype_name"}),
				new VoDataInfo("pk_accsubj", new String[]{"accsubj_name"}),
				new VoDataInfo("pk_currency", new String[]{"currency_name"}),
				new VoDataInfo("pk_accsubj", new String[]{"accsubj_name"})
		};
		new AppendDataManager().appendNameFieldValues(new SuperVO[] { headVO }, dataBaseDataInfos, voDataInfos);
		return headVO;
	}

	public IDataSource getPrintDs(String billId, String billtype, String checkman) throws BusinessException {
		return new BillPrintDataSource(this).getPrintDataSource(billId, billtype, checkman);
	}

}
